package com.bjpowernode.crm.workbench.service.serviceimpl;

import com.bjpowernode.crm.workbench.dao.ClueActivityRelationDao;
import com.bjpowernode.crm.workbench.eneity.ClueActivityRelation;
import com.bjpowernode.crm.workbench.exception.ClueException;
import com.bjpowernode.crm.workbench.service.ClueActivityRelationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class ClueActivityRelationServiceImpl implements ClueActivityRelationService {
    @Autowired
    private ClueActivityRelationDao relationDao;
    @Override
    public Boolean delRelation(String id) throws ClueException {
        Boolean flag=true;
        int result=relationDao.delRelation(id);
        if (result!=1){
            flag =false;
            throw new ClueException("解除关联信息失败");
        }
        return flag;
    }

    @Override
    @Transactional
    public boolean insertActivityByIds(List<ClueActivityRelation> relationList) throws ClueException {
        //调用service
        boolean flag=true;
        int result=relationDao.insertActivityByIds(relationList);
        if (result!=relationList.size()){
            flag=false;
            throw new ClueException("关联信息添加失败");
        }
        return flag;
    }
}
